#include <iostream>
#include <string>
using namespace std;
int match_delete(string *t, string *p)
{
    int m = (*t).length(), n = (*p).length();
    for (int i = 0; i <= m - n; i++)
    {
        int j;
        for (j = 0; j < n; j++)
        {
            if ((*p)[j] != (*t)[i+j])
                break;
        }
        if (j == n)
            return i;
    }
    return -1;
}
int main()
{
    string *t = new string("abcabcabcdddfyuiyuiabc");
    string *p = new string("abc");
    int tlength = (*t).length();
    int plength = (*p).length();
    while (tlength >= plength)
    {
        int i = match_delete(t, p);
        if (i == -1)
            break;
        (*t).erase(i, plength);
        tlength = (*t).length();
    }
    cout << (*t) << endl;
    return 0;
}
